// pages/my/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    top: 0,
    type: [
      {
        id: 1,
        name: '待付款',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/my_order_1.png'
      },
      {
        id: 2,
        name: '待发货',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/my_order_2.png'
      },
      {
        id: 3,
        name: '待收货',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/my_order_3.png'
      },
      {
        id: 4,
        name: '待评价',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/my_order_4.png'
      },
      {
        id: 5,
        name: '退款/售后',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/my_order_5.png'
      },
    ],
    more_type: [
      {
        id: 1,
        name: '服务',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/More/24.png'
      },
      {
        id: 2,
        name: '收货地址',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/More/dizhi.png'
      },
      {
        id: 3,
        name: '折扣',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/More/jifen.png'
      },
      {
        id: 4,
        name: '开店',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/More/kaidian.png'
      },
      {
        id: 5,
        name: '客服',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/More/kefu.png'
      },
      {
        id: 6,
        name: '评价',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/More/pingfen.png'
      },
      {
        id: 7,
        name: '疑问',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/More/wenti.png'
      },
      {
        id: 8,
        name: '优惠券',
        icon: 'https://xckf-bucket.oss-cn-guangzhou.aliyuncs.com/102/images/my/More/youhuijuan.png'
      },
    ],
    user_info: {}
  },
  onPath: function (e) {
    switch (e.currentTarget.dataset.path) {
      case 2:
        wx.navigateTo({
          url: '/pagesA/pages/address/index',
        })
        break;
    }
  },
  toLogin: function (e) {
    // 跳转后关闭之前的页面
    wx.redirectTo({
      url: '/pages/login/index',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.getSystemInfo({
      success: (res) => {
        this.setData({
          top: res.safeArea.top
        })
      }
    })
    if (!wx.getStorageSync('token')) {
      return wx.showToast({
        title: '请先登录！',
        icon: 'error'
      })
    }

    console.log(wx.getStorageSync('userinfo'));

    this.setData({
      user_info: JSON.parse(wx.getStorageSync('userinfo'))
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})